<template>
    <div style="height:100%;width:100%;position:relative;">
        <div class="pagetop">
            <div style="width:100%">
                <div style="width:50%;float:left">
                    <table style="font-size:12px" class="table1style">
                        <tr>
                            <td>快速查询</td>
                            <td>
                                <el-input v-model.trim="txtsearch" clearable placeholder="报告单元名称|报告单元ID" @keyup.enter.native="InitPageDate"></el-input>
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="width:50%;float:left;">
                    <table style="float:right">
                        <tr>
                            <td>
                                <el-button icon="el-icon-search" @click="RefreshData" type="primary">查 询</el-button>
                            </td>
                            <td align="center">
                                <el-button icon="el-icon-document" @click="btnModifySave">保 存</el-button>
                            </td>
                            <td align="center">
                                <el-button @click="btnStyleListScene">样式组合维护</el-button>
                            </td>
                            <td align="center">
                                <el-button @click="myRptunitid='';forcecover='0';dialogRptunit=true">复制到其他报告单元</el-button>
                            </td>
                            <!-- <td align="center">
                                <el-button icon="el-icon-refresh-right" @click="btnExitFun">退 出</el-button>
                            </td> -->
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div class="pagecenter">
            <div class="middle-center">
                <vxe-table :data.sync="list" :loading="loading" :keyboard-local-config="keyLocalConfig" :select-config="selectConfig" :sort-config="{trigger: 'cell'}" @current-change="currentChangeEvent" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytable-style" :cell-class-name="cellClassName" highlight-hover-column ref="xTable" resizable show-overflow="tooltip" size="mini" stripe :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}">
                    <vxe-table-column field="PrintSign" title="结果标识符号调整" width="60" header-align="center" align="center">
                        <template v-slot="{row}">
                            <div @click="PrintSignModify(row)" style="font-size:18px;color:#0066CC"><i class="el-icon-edit-outline"></i></div>
                        </template>
                    </vxe-table-column>
                    <!-- <vxe-table-column field="rptunitid" title="报告单元ID" width="80" header-align="center"> </vxe-table-column> -->
                    <vxe-table-column field="rptunitname" title="报告单元名称" width="170" header-align="center">
                        <template v-slot="{row}">
                            <div>{{"["+row.rptunitid+"]"+row.rptunitname}}</div>
                        </template>
                    </vxe-table-column>

                    <vxe-table-column field="rptstyleidname" title="科内报告样式(双击开窗)" width="190" key="rptstyleid" header-align="center">
                        <template v-slot="{ row,column }">
                            <div v-if="!row.rptstyleunitname">
                                <div v-if="!!row.rptstyleidname"><a href="javascript:void(0)" @click="RptStyleSetting(row.rptstyleid)"><i class="el-icon-edit"></i></a>
                                    {{!!row.rptstyleidname? "("+row.rptstyleid+")":""}}
                                    <el-input placeholder="" v-model="row.rptstyleidname" @dblclick.native="OpenDialog(row,column)" style="width:80%" readonly @clear="inputClear(row,column)" :clearable="true"></el-input>
                                </div>
                                <div v-else>
                                    <el-input placeholder="" v-model="row.rptstyleidname" @dblclick.native="OpenDialog(row,column)" style="width:100%" readonly @clear="inputClear(row,column)" :clearable="true"></el-input>
                                </div>
                            </div>
                            <div v-else>
                                <a href="javascript:void(0)" @click="RptStyleSetting(row.rptstyleid)"><i class="el-icon-edit"></i></a>
                                {{!!row.rptstyleidname? "("+row.rptstyleid+")":""}}
                                <el-input placeholder="" v-model="row.rptstyleidname"  style="width:80%" @clear="inputClear(row,column)" :clearable="true">
                                </el-input>
                            </div>
                        </template>
                    </vxe-table-column>

                    <vxe-table-column field="rptstyle2idname" title="科内报告样式2(双击开窗)" width="190" key="rptstyle2id" header-align="center">
                        <template v-slot="{ row,column }">
                            <div v-if="!row.rptstyleunitname">
                                <div v-if='!!row.rptstyle2idname'>
                                    <a href="javascript:void(0)" @click="RptStyleSetting(row.rptstyle2id)"><i class="el-icon-edit"></i></a>
                                    {{!!row.rptstyle2idname? "("+row.rptstyle2id+")":""}}
                                    <el-input placeholder="" v-model="row.rptstyle2idname" @dblclick.native="OpenDialog(row,column)" style="width:80%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                                <div v-else>
                                    <el-input placeholder="" v-model="row.rptstyle2idname" @dblclick.native="OpenDialog(row,column)" style="width:100%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                            </div>
                            <div v-else>
                                <a href="javascript:void(0)" @click="RptStyleSetting(row.rptstyle2id)"><i class="el-icon-edit"></i></a>
                                {{!!row.rptstyle2idname? "("+row.rptstyle2id+")":""}}
                                <el-input placeholder="" v-model="row.rptstyle2idname" disabled style="width:80%" @clear="inputClear(row,column)" :clearable="true">
                                </el-input>
                            </div>
                        </template>
                    </vxe-table-column>

                    <vxe-table-column field="autoprint_rptstyleidname" title="自助打印报告样式(双击开窗)" width="200" key="autoprint_rptstyleid" header-align="center">
                        <template v-slot="{ row,column }">
                            <div v-if="!row.rptstyleunitname">
                                <div v-if='!!row.autoprint_rptstyleidname'>
                                    <a href="javascript:void(0)" @click="RptStyleSetting(row.autoprint_rptstyleid)"><i class="el-icon-edit"></i></a>
                                    {{!!row.autoprint_rptstyleidname? "("+row.autoprint_rptstyleid+")":""}}
                                    <el-input placeholder="" v-model="row.autoprint_rptstyleidname" @dblclick.native="OpenDialog(row,column)" style="width:80%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                                <div v-else>
                                    <el-input placeholder="" v-model="row.autoprint_rptstyleidname" @dblclick.native="OpenDialog(row,column)" style="width:100%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                            </div>
                            <div v-else>
                                <a href="javascript:void(0)" @click="RptStyleSetting(row.autoprint_rptstyleid)"><i class="el-icon-edit"></i></a>
                                {{!!row.autoprint_rptstyleidname? "("+row.autoprint_rptstyleid+")":""}}
                                <el-input placeholder="" v-model="row.autoprint_rptstyleidname" disabled style="width:80%" @clear="inputClear(row,column)" :clearable="true">
                                </el-input>
                            </div>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="autoprint_rptstyle2idname" title="自助打印报告样式2(双击开窗)" width="200" key="autoprint_rptstyle2id" header-align="center">
                        <template v-slot="{ row ,column}">
                            <div v-if="!row.rptstyleunitname">
                                <div v-if='!!row.autoprint_rptstyle2idname'>
                                    <a href="javascript:void(0)" @click="RptStyleSetting(row.autoprint_rptstyle2id)"><i class="el-icon-edit"></i></a>
                                    {{!!row.autoprint_rptstyle2idname? "("+row.autoprint_rptstyle2id+")":""}}
                                    <el-input placeholder="" v-model="row.autoprint_rptstyle2idname" @dblclick.native="OpenDialog(row,column)" style="width:80%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                                <div v-else>
                                    <el-input placeholder="" v-model="row.autoprint_rptstyle2idname" @dblclick.native="OpenDialog(row,column)" style="width:100%" readonly @clear="inputClear(row,column)" :clearable="true">
                                    </el-input>
                                </div>
                            </div>
                            <div v-else>
                                <a href="javascript:void(0)" @click="RptStyleSetting(row.autoprint_rptstyle2id)"><i class="el-icon-edit"></i></a>
                                {{!!row.autoprint_rptstyle2idname? "("+row.autoprint_rptstyle2id+")":""}}
                                <el-input placeholder="" v-model="row.autoprint_rptstyle2idname" disabled style="width:80%" @clear="inputClear(row,column)" :clearable="true">
                                </el-input>
                            </div>
                        </template>
                    </vxe-table-column>

                    <vxe-table-column field="rptstyleunitname" title="报告单样式组合名称" width="150" sortable header-align="center" :edit-render="{name:'select',options:LabStyleNameList }">
                    </vxe-table-column>

                    <vxe-table-column field="doublerptstyle" title="双报告模式" width="50" header-align="center" align="center">
                        <template v-slot="{row}">
                            <el-checkbox true-label="1" false-label="0" v-model="row.doublerptstyle"></el-checkbox>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="rpt2itemcount" title="超出多少行使用报告2" width="70" header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>

                    <vxe-table-column field="rptstyleusesp" title="使用报告项目中样式" width="70" header-align="center" align="center">
                        <template v-slot="{row}">
                            <el-checkbox true-label="1" false-label="0" v-model="row.rptstyleusesp"></el-checkbox>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="rptdivbygroup" title="根据项目分组拆分打印" width="70" header-align="center" align="center">
                        <template v-slot="{row}">
                            <el-checkbox true-label="1" false-label="0" v-model="row.rptdivbygroup"></el-checkbox>
                        </template>
                    </vxe-table-column>

                    <vxe-table-column field="reporttitle" title="报告单标题" width="100" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>

                    <!-- <vxe-table-column field="rptstyleunitname" title="报告单样式组合名称" width="150" sortable header-align="center" :edit-render="{name:'select', options: LabStyleNameList }"></vxe-table-column> -->

                </vxe-table>
            </div>
        </div>
        <!--报告样式组合弹窗--->
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="报告单样式组合" :visible.sync="ScenedialogVisible" width="90%" v-if="scenediacls">

            <el-dialog title="输入应用场景名称（即策略名称）:" width="40%" :visible.sync="dialogFormVisible" append-to-body>
                <el-form>
                    <el-form-item>
                        <el-input v-model.trim="scenename" autocomplete="off" placeholder="场景名称" ref="refscenename" @keyup.native="banInputSapce($event)"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="dialogFormVisibleSave">确 定</el-button>
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                </div>
            </el-dialog>

            <div style="height:450px">
                <vxe-toolbar>
                    <template v-slot:buttons>
                        <table>
                            <tr>
                                <td> 送检医院</td>
                                <td>
                                    <rm-ddl-common @change="hospitalchange" datatype="hospital" dataname="医院" v-model="hospitalval" width="200px"></rm-ddl-common>
                                </td>
                            </tr>
                        </table>
                    </template>
                </vxe-toolbar>

                <vxe-table border size="mini" ref="xTbaleSence" height="420" class="myclass" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :data.sync="tableDataStyle" align="center" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" @cell-dblclick="popOpendialog">
                    <vxe-table-column field="rptstyleunitname" title="报告单组合名称" show-overflow width="120" :edit-render="{name: 'input', autoselect: true}" align="left" header-align="center"></vxe-table-column>
                    <vxe-table-column :title="sitems.title" v-for="(sitems,sindex) in tableColumnStyle" :key="sindex">
                        <template v-for="(kitem,kindex) in sitems.content">
                            <vxe-table-column :field="kitem.field" :title="kitem.title+'(双击开窗)'" width="170" :key="kindex" v-if="kitem.IorS=='s1'" :formatter="formatdata" align="left" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column :field="kitem.field" :title="kitem.title" width="70" :key="kindex" :edit-render="{name: 'input', autoselect: true}" v-else-if="kitem.IorS=='I'">
                            </vxe-table-column>
                            <vxe-table-column :field="kitem.field" :title="kitem.title+'(双击开窗)'" width="170" :key="kindex" v-else-if="kitem.IorS=='s2'" :formatter="formatdata" align="left" header-align="center">
                            </vxe-table-column>
                        </template>
                    </vxe-table-column>
                </vxe-table>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="SceneDialogAdd()" :disabled="hosdisabled">新 增</el-button>
                <el-button @click="SceneDialogDelete()" :disabled="hosdisabled">删 除</el-button>
                <el-button @click="SceneDialogRefresh()">刷 新</el-button>
                <el-button @click="SceneDialogAddScene()" :disabled="hosdisabled">新增场景</el-button>
                <el-button @click="SceneDialogSave()">保 存 </el-button>
                <el-button @click="ScenedialogClose">关 闭</el-button>
            </span>
        </el-dialog>
        <!--报告单元打印提示弹窗--->
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="报告单元打印提示调整" :visible.sync="dialogLabRptunitSign">
            <vxe-table :data.sync="LabRptunitSignData" border size="mini" ref="xTbalesign" height="300" show-header-overflow highlight-current-row highlight-hover-row show-overflow resizable stripe header-align="center" class="signclass" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}">
                <vxe-table-column field="rptunitid" title="报告单组合ID" width="120"></vxe-table-column>
                <vxe-table-column field="rptunitname" title="报告单组合名称" width="150"></vxe-table-column>
                <vxe-table-column field="resultflag" title="结果标志" align="center" width="80">
                </vxe-table-column>
                <vxe-table-column field="printsign" title="打印提示" width="120" align="center" :edit-render="{name: 'select', options: printsignOption}"></vxe-table-column>
            </vxe-table>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogLabRptunitSignSave()">保 存 </el-button>
                <el-button @click="dialogLabRptunitSign=false">取 消</el-button>
            </span>
        </el-dialog>

        <!--请选择报告单元-->
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择报告单元" :visible.sync="dialogRptunit" width="450px">
            <div style="padding:20px">
                <table class="tablestyle">
                    <tr>
                        <td>报告单元ID</td>
                        <td>
                            <rm-ddl-rptunit prgno="MNG135" @change="rptunitChange" :clearable="true" defaultflag="" v-model="myRptunitid" width="200px" :multiple_choice="true" :targetId="true"></rm-ddl-rptunit>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <el-checkbox v-model="forcecover" true-label="1" false-label="0">强制覆盖</el-checkbox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <span style="color:red">①双击选择报告单元或者输入报告单元ID(以,连接)<br>②强制覆盖模式下将以当前选中数据覆盖目标报告单元数据<br>③非强制模式下若目标报告单元对应字段存在值则不覆盖</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="CopyToRptunit">确 定</el-button>
                <el-button @click="dialogRptunit = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
    name: "MNG135",
    data() {
        return {
            scenediacls: false,
            scenename: "",
            hospitalval: "All",
            dialogFormVisible: false,
            isdisabled: false,
            hosdisabled: false,
            txtsearch: "",
            loading: false,
            scenetyleid: 0,
            ScenedialogVisible: false,
            tableData: [],
            tableColumn: [],
            LabStyleNameList: [],
            LabStyleList: [],
            LabStyleListCopy: [],
            TempList: "",
            dialogStyleVisible: false,
            poptableDataStyle: [],
            loadingStyle: false,
            dataFormid: false,
            poptableColumnStyle: [],
            tempindex: 0,
            cities: [],
            tableDataStyle: [],
            StyleOptions: [],
            printsignOption: [
                { label: "×", value: "×" },
                { label: "↑", value: "↑" },
                { label: "↓", value: "↓" },
                { label: " ", value: " " },
                { label: "＋", value: "＋" },
                { label: "±", value: "±" },
                { label: "☆", value: "☆" },
                { label: "-", value: "-" },
                { label: "＋-", value: "＋-" },
                { label: "*", value: "*" },
                { label: "★", value: "★" },
                { label: "▲", value: "▲" },
                { label: "Δ", value: "Δ" },
            ],
            tableColumnStyle: [
                {
                    title: "科内打印",
                    content: [
                        {
                            title: "样式1",
                            field: "kndyys1",
                            IorS: "s1",
                        },
                        {
                            title: ">行数",
                            field: "kndadyhs",
                            IorS: "I",
                        },
                        {
                            title: "样式2",
                            field: "kndyys2",
                            IorS: "s2",
                        },
                    ],
                },
                {
                    title: "自助打印",
                    content: [
                        {
                            title: "样式1",
                            field: "zzdyys1",
                            IorS: "s1",
                        },
                        {
                            title: ">行数",
                            field: "zzdydyhs",
                            IorS: "I",
                        },
                        {
                            title: "样式2",
                            field: "zzdyys2",
                            IorS: "s2",
                        },
                    ],
                },
            ],
            okFirstLoading: false,
            isFirstLoading: false,
            selectConfig: { tigger: "row" },
            keyConfig: {
                isDel: true,
                isTab: true,
                isEdit: true,
            },
            keyLocalConfig: {
                isArrow: true,
            },
            dialogLabRptunitSign: false,
            LabRptunitSignData: [],
            rptunitid: "",
            dialogRptunit: false,
            myRptunitid: "",
            forcecover: "0",
        };
    },
    created() {
        this.InitPageDate(); //初始化主列表
        this.initRptunitSign(); //初始化报告单元打印提示
        this.ddlInitialList(); //初始化下拉框的数据
        // this.Qlab_rptstyleunit();
        // this.QLab_RptStyle();
    },
    computed: {
        list() {
            let filterName = this.txtsearch.trim();
            if (filterName) {
                let rest = this.tableData.filter((item) => {
                    return item.rptunitname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.rptunitid == filterName;
                });
                return rest;
            } else {
                return this.tableData;
            }
        },
    },
    watch: {
        txtsearch(val, oldval) {
            if (val != oldval) {
                this.tempindex = 0;
            }
            this.$nextTick(() => {
                let currentrow = this.$refs.xTable.getData(this.tempindex);
                if (currentrow) {
                    this.okFirstLoading = false;
                    this.$refs.xTable.setCurrentRow(currentrow);
                }
            });
        },
    },
    mounted() {},
    updated() {
        if (this.okFirstLoading) {
            this.$nextTick(() => {
                let currentrow = this.$refs.xTable.getData(this.tempindex);
                if (currentrow) {
                    this.okFirstLoading = false;
                    this.$refs.xTable.setCurrentRow(currentrow);
                }
            });
        }
        if (this.isFirstLoading) {
            this.$nextTick(() => {
                let currentrow = this.$refs.xTbaleSence.getData(0);
                if (currentrow) {
                    this.isFirstLoading = false;
                    this.$refs.xTbaleSence.setCurrentRow(currentrow);
                }
            });
        }
    },
    methods: {
        banInputSapce(e) {
            if (e.code == "Space") {
                this.scenename = this.scenename.replace(/\s+/g, "");
            }
        },
        InitialList() {
            this.LabStyleListCopy = this.LabStyleList;
        },
        hospitalchange(code, name) {
            this.hospitalval = code;
            // if (this.hospitalval != "All") {
            //     this.hosdisabled = true;
            // } else {
            //     this.hosdisabled = false;
            // }
            //当初是怕一家医院删除了组合，另外一家又在用，笪工建议：增加控制，如果是系统管理员进来就可以编辑（是全局的管理员，而不是这家医院的管理员）
            let loginutype = this.$tool.getSession(this.$tool.loginutype);
            //console.log("sas", loginutype);
            if (loginutype != "G") {
                this.hosdisabled = true;
            } else {
                this.hosdisabled = false;
            }
        },
        ScenedialogClose() {
            this.scenediacls = false;
            this.ScenedialogVisible = false;
        },
        SceneDialogAdd() {
            this.$refs.xTbaleSence.insert().then(({ row }) => {
                this.$nextTick(() => {
                    this.$refs.xTbaleSence.setCurrentRow(row);
                    this.$refs.xTbaleSence.setActiveRow(row, "rptstyleunitname");
                });
            });
        },
        SceneDialogDelete() {
            try {
                var delrow = this.$refs.xTbaleSence.getCurrentRow();
                if (delrow) {
                    this.$confirm("您确定删除该条数据吗？", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    })
                        .then(() => {
                            var alld = this.$refs.xTbaleSence.tableData;
                            var rowindex = alld.indexOf(delrow);
                            this.$refs.xTbaleSence.remove(delrow);
                            let havedata = this.$refs.xTbaleSence.tableData;
                            if (havedata.length > 0) {
                                if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                                let selectrow = havedata[rowindex];
                                this.$refs.xTbaleSence.setCurrentRow(selectrow);
                            }
                        })
                        .catch(() => {});
                }
            } catch (e) {
                console.log("error", e);
            }
        },
        popOpendialog({ row, column }) {
            let nodialogArr = ["zzdydyhs", "kndadyhs"];
            if (!nodialogArr.includes(column.property) && column.property.indexOf("zdystylecount") == -1) {
                this.$rm_RptunitStyle({
                    btn: {
                        confirmBtnText: "确定",
                        cancelBtnText: "取消",
                    },
                })
                    .then((res) => {
                        row[column.property] = res.code;
                        this.$refs.xTbaleSence.updateListenter();
                    })
                    .catch((e) => {
                        this.$alert(e, "error");
                    });
            }
        },
        OpenDialog(row, column) {
            this.$rm_RptunitStyle({
                btn: {
                    confirmBtnText: "确定",
                    cancelBtnText: "取消",
                },
            })
                .then((res) => {
                    if (column.property == "rptstyleidname") {
                        row.rptstyleid = res.code;
                        row.rptstyleidname = res.name;
                    } else if (column.property == "rptstyle2idname") {
                        row.rptstyle2id = res.code;
                        row.rptstyle2idname = res.name;
                    } else if (column.property == "autoprint_rptstyleidname") {
                        row.autoprint_rptstyleid = res.code;
                        row.autoprint_rptstyleidname = res.name;
                    } else if (column.property == "autoprint_rptstyle2idname") {
                        row.autoprint_rptstyle2id = res.code;
                        row.autoprint_rptstyle2idname = res.name;
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        formatdata({ cellValue, row, column }) {
            try {
                let data = this.StyleOptions.find((m) => m.value == cellValue);
                if (!data) {
                    return cellValue;
                } else {
                    return data.label;
                }
            } catch (e) {
                return cellValue;
            }
        },
        SceneDialogRefresh() {
            this.Qlab_rptstyleunit();
        },
        SceneDialogAddScene() {
            this.scenename = " ";
            this.$nextTick(() => {
                this.$refs.refscenename.focus();
            });
            this.dialogFormVisible = true;
        },
        dialogFormVisibleSave() {
            this.scenetyleid++;
            var content = {
                title: this.scenename,
                content: [
                    {
                        title: "样式1",
                        field: "zdystyle1_" + this.scenetyleid,
                        IorS: "s1",
                    },
                    {
                        title: ">行数",
                        field: "zdystylecount_" + this.scenetyleid,
                        IorS: "I",
                    },
                    {
                        title: "样式2",
                        field: "zdystyle2_" + this.scenetyleid,
                        IorS: "s2",
                    },
                ],
            };
            this.TempList += this.scenename + "|zdystyle1_$zdystylecount_$zdystyle2_|" + this.scenetyleid + "#";
            let haveflag = false;
            try {
                this.tableColumnStyle.forEach((item) => {
                    if (this.scenename == item.title) {
                        haveflag = true;
                        throw Error();
                    }
                });
            } catch (e) {}
            if (haveflag == false) {
                this.tableColumnStyle.push(content);
            } else {
                this.$message({
                    type: "warning",
                    message: "已存在的名称",
                });
                return false;
            }
            //console.log(this.tableDataStyle);
            // this.tableDataStyle.forEach(ele=>{
            //     ele["zdystyle1_1"]="";
            //     ele["zdystylecount_1"]="";
            //     ele["zdystyle2_1"]="";
            //    console.log(ele);
            // })
            // this.$refs.xTbaleSence.loadData()
            // this.$refs.xTbaleSence.refreshColumn(); //loadColumn(this.tableColumnStyle);
            this.dialogFormVisible = false;
        },
        async Qlab_rptstyleunit() {
            try {
                const response = await this.$tool.request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "Qlab_rptstyleunit",
                        hospitalcode: this.hospitalval,
                    },
                });
                this.tableDataStyle = response.rdt;
                let k = this.tableColumnStyle.length;
                if (k > 2) {
                    k = k - 2;
                }
                this.tableColumnStyle.splice(2, k);
                let columnList = response.list;
                this.$nextTick(() => {
                    if (columnList.length > 0) {
                        columnList.forEach((ele) => {
                            var content = {
                                title: ele.Item1,
                                content: [
                                    {
                                        title: "样式1",
                                        field: ele.Item2,
                                        IorS: "s1",
                                    },
                                    {
                                        title: ">行数",
                                        field: ele.Item3,
                                        IorS: "I",
                                    },
                                    {
                                        title: "样式2",
                                        field: ele.Item4,
                                        IorS: "s2",
                                    },
                                ],
                            };
                            let haveflag = false;
                            try {
                                this.tableColumnStyle.forEach((item) => {
                                    if (ele.Item1 == item.title) {
                                        haveflag = true;
                                        throw Error();
                                    }
                                });
                            } catch (e) {}
                            if (haveflag == false) {
                                this.tableColumnStyle.push(content);
                            }
                        });
                    }
                });
                this.isFirstLoading = true;
            } catch (e) {
                console.log("err", r);
            }
        },
        SceneDialogSave() {
            let columnstr = "";
            let StyleModifyList = this.$refs.xTbaleSence.tableData;
            let StyleDeleteList = this.$refs.xTbaleSence.getRemoveRecords();
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "SceneDialogSave",
                        oldinfo: this.tableDataStyle,
                        saveinfo: StyleModifyList,
                        nameinfo: this.TempList,
                        StyleDeleteList: StyleDeleteList,
                        hospitalcode: this.hospitalval,
                    },
                })
                .then((response) => {
                    if (response.errcode == "1") {
                        this.Qlab_rptstyleunit();
                        this.$message({
                            message: "操作成功！",
                            type: "success",
                        });
                        this.TempList = "";
                        //this.ScenedialogVisible = false;
                    } else {
                        this.$message({
                            message: "保存失败！" + response.errmsg,
                            type: "warning",
                        });
                    }
                })
                .catch((e) => {
                    console.log("erro", e);
                });
        },
        ddlInitialList() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "ddlInitialList",
                    },
                })
                .then((response) => {
                    this.LabStyleNameList = response.dt;
                    this.LabStyleList = response.dt1;
                    this.StyleOptions = response.dt1;
                })
                .catch((e) => {
                    console.log("erro", e);
                });
        },
        initRptunitSign() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "initRptunitSign",
                    },
                })
                .then((res) => {
                    if (res.errcode == "0") {
                        this.$alert("报告单元打印提示初始化失败！" + res.errcode);
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        InitPageDate() {
            this.loading = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "InitPageDate",
                        // txtsearch: this.txtsearch
                    },
                })
                .then((res) => {
                    this.loading = false;
                    this.tableColumn = res.Cols;
                    this.tableData = res.Data;
                    this.okFirstLoading = true;
                })
                .catch((e) => {
                    this.loading = false;
                    console.log("error", e);
                });
        },
        RefreshData() {
            this.ddlInitialList();
            this.InitPageDate();
        },
        async btnStyleListScene() {
            await this.Qlab_rptstyleunit();
            this.TempList = "";
            this.ScenedialogVisible = true;
            this.scenediacls = true;
        },
        btnExitFun() {},
        currentChangeEvent({ row, rowIndex }) {
            this.tempindex = rowIndex;
            this.rptunitid = row.rptunitid;
        },
        btnModifySave() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "Save",
                        saveinfo: this.$refs.xTable.getRecordset(),
                    },
                })
                .then((response) => {
                    if (response.errcode == "1") {
                        this.$message({
                            message: "操作成功！",
                            type: "success",
                        });
                        this.InitPageDate();
                    } else {
                        this.$message({
                            message: "保存失败！" + response.errmsg,
                            type: "warning",
                        });
                    }
                })
                .catch((e) => {
                    console.log("erro", e);
                });
        },
        cellClassName({ row, column }) {
            if (column.property == "rptunitid") {
                return "col-orange";
            } else {
                if (column.property == "rptstyleid" || column.property == "rptstyle2id" || column.property == "autoprint_rptstyleid" || column.property == "autoprint_rptstyle2id") {
                    if (row.rptstyleunitname != "") {
                        return "col-orange";
                    } else {
                        return "";
                    }
                } else {
                    return "";
                }
            }
        },
        RptStyleSetting(rptstyleId) {
            if (!!rptstyleId) {
                const rloading = this.$pub.openLoading(this, "样式加载中");
                this.$pub.printreport(this, "", "3", rptstyleId);
                setTimeout(() => {
                    rloading.close();
                    // this.loading = false;
                }, 6000);
            } else {
                this.$alert("未获取到报告单样式！", "信息");
            }
        },
        async PrintSignModify(row) {
            try {
                this.rptunitid = row.rptunitid;
                const res = await this.$tool.request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "PrintSignModify",
                        rptunitid: row.rptunitid,
                    },
                });
                this.LabRptunitSignData = res.data;
                this.dialogLabRptunitSign = true;
            } catch (e) {
                this.$message.warning(e);
            }
        },
        dialogLabRptunitSignSave() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "PrintSignSave",
                        rptunitid: this.rptunitid,
                        saveinfo: this.$refs.xTbalesign.getRecordset(),
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.$message({
                            message: "保存成功！",
                            type: "success",
                            duration: "1000",
                            showClose: true,
                        });
                    } else {
                        this.$alert("保存失败！" + res.errmsg);
                    }
                })
                .catch((e) => {
                    this.$alert("保存出错" + e);
                });
        },
        inputClear(row, column) {
            if (column.property == "rptstyleidname") {
                row.rptstyleidname = "";
                row.rptstyleid = "";
            } else if (column.property == "rptstyle2idname") {
                row.rptstyle2idname = "";
                row.rptstyle2id = "";
            } else if (column.property == "autoprint_rptstyleidname") {
                row.autoprint_rptstyleidname = "";
                row.autoprint_rptstyleid = "";
            } else if (column.property == "autoprint_rptstyle2idname") {
                row.autoprint_rptstyle2idname = "";
                row.autoprint_rptstyle2id = "";
            } else {
            }
        },
        //将样式复制到其他报告单元
        CopyToRptunit() {
            let chkrow = this.$refs.xTable.getCurrentRow();
            if (chkrow) this.rptunitid = chkrow.rptunitid;
            else this.rptunitid = "";
            if (!this.rptunitid) {
                this.$alert("未获取到源报告单元！", "提示");
                return false;
            }
            if (!this.myRptunitid) {
                this.$alert("未获取到目标报告单元！", "提示");
                return false;
            }
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG135",
                    method: "post",
                    data: {
                        action: "CopyToRptunit",
                        rptunitid: this.rptunitid,
                        copyToRptunitid: this.myRptunitid,
                        forcecover: this.forcecover,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.$message({
                            message: "保存成功！",
                            type: "success",
                            duration: "1000",
                            showClose: true,
                        });
                        this.dialogRptunit = false;
                        this.InitPageDate();
                    } else {
                        this.$alert("保存失败！" + res.errmsg);
                    }
                })
                .catch((e) => {
                    this.$alert("保存出错" + e);
                });
        },
        rptunitChange(code, name) {
            this.myRptunitid = code;
        },
    },
};
</Script>

<style scoped>
.pagetop {
    width: 100%;
    height: 35px;
    display: -webkit-box;
    -webkit-box-pack: right;
    -webkit-box-align: center;
    border: 1px solid #ccc;
    position: absolute;
    z-index: 99;
}

.pagecenter {
    position: absolute;
    top: 40px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}

.middle-center {
    background-color: blueviolet;
    position: absolute;
    height: 100%;
    left: 0px;
    right: 0px;
    overflow: auto;
}
.tablestyle tr td {
    padding: 8px;
}

.formtablestyle {
    height: 100%;
    font-size: 12px;
    color: #333;
    width: 100%;
}

.formtablestyle tr td:nth-child(1),
td:nth-child(3) {
    text-align: right;
}
.table1style tr td {
    padding: 0px 2px 0px 5px;
}

/deep/.myclass .vxe-table--header .vxe-header--column {
    border-right: 1px solid #cccccc;
    border-bottom: 1px solid #ccc;
}

/deep/.myclass tr td div .el-input__inner {
    border: 1px solid rgba(255, 254, 254, 0) !important;
    background-color: rgba(255, 254, 254, 0) !important;
}

/deep/ .mytable-style.vxe-table .vxe-body--column.col-orange {
    background-color: #ccc;
}
/deep/ .mytable-style tr td div .el-input__inner {
    /* border: 1px solid rgba(255, 254, 254, 0) !important;*/
    background-color: rgba(255, 254, 254, 0) !important;
}

/deep/.middle-center tr td div .el-input__inner {
    border: 1px solid rgba(255, 254, 254, 0) !important;
    background-color: rgba(255, 254, 254, 0) !important;
}

/deep/.signclass .vxe-table.size--mini {
    font-size: 19px;
}
</style>